// JavaScript Document
;(function($){
	$.fn.long=function(obj){
		var length={
				"element":"elmt",   //操作对象
				"action":"keyup",   //事件1
				"actions":"blur",   //事件2
				"stringl":"0",      //字符最短长度
				"stringls":"50",    //字符最长长度
				"reg":/^\d{1,15}$/,     //正则判断
				"stavalue":"starting",   //初始值
				"point":"请正确输入"      //错误提示
			}
		var expand=$.extend(length, obj);
		var value=length.stavalue;
		/*var points = $(length.element).on(length.actions, function(){
			alert(length.point);
		});*/
		$(length.element).on(length.action, function(){
			value=$(length.element).val();
			//alert(value);
			if(value.indexOf(" ")==0){
				value="";
				$(length.element).val("");
			}
			if(value.indexOf(" ")>=1){
				value=value.replace(/\s+/,"");  //去除内部空格
				//value=value.substring(0, value.length-1);   //substring提取下标同[)
				$(length.element).val(value);
			}
			if(length.reg.test(value)){
				if(value.length<length.stringl){
					$(length.element).val(value);
					//points();
				}
				if(value.length>length.stringls){
					value=value.substring(0, length.stringls);
					$(length.element).val(value);
				}
			}else{
				$(length.element).val(length.stavalue);
				//points();
			}
			
		});
		
	};
	
	
})(jQuery);

